package com.produce.user.service;

import com.common.dao.base.constant.SystemStaticConst;
import com.common.dao.base.dao.BaseDao;
import com.common.dao.base.service.BaseService;
import com.github.pagehelper.PageHelper;
import com.produce.user.dao.OrganizationalStructureDao;
import com.produce.user.entity.OrganizationalStructure;
import com.produce.user.mapper.OrganizationalStructureMapper;
import com.produce.user.util.OrgInstall;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 类描述：组织架构的service
 * @author linzf
 */
@Service
public class OrganizationalStructureService extends BaseService<OrganizationalStructure> {

    @Autowired
    private OrganizationalStructureDao organizationalStructureDao;
    @Autowired
    private OrganizationalStructureMapper organizationalStructureMapper;

    @Override
    protected BaseDao<OrganizationalStructure> getDao() {
        return this.organizationalStructureDao;
    }

    /**
     * 功能描述：获取所有的组织架构的数据
     * @return
     */
    public Map<String,Object> getAllOrgList(){
        Map<String,Object> result = new HashMap<String, Object>(3);
        result.put(SystemStaticConst.RESULT, SystemStaticConst.SUCCESS);
        result.put(SystemStaticConst.MSG,"获取所有的组织架构数据成功！");
        OrganizationalStructure query = new OrganizationalStructure();
        PageHelper.startPage(1, 9999);
        result.put(SystemStaticConst.ENTITY, OrgInstall.installOrg(organizationalStructureMapper.organizationalsStructureToOrganizationalStructureDto(organizationalStructureDao.select(query))));
        return result;
    }



}
